import { createRouter, createWebHashHistory } from 'vue-router';
import navigation from '@/router/navigation';
import { resolvePagesRoutes } from '@/router/pages';

const routes = [
  {
    path: '/:catchAll(.*)',
    redirect: '/NotFound'
  }
];
// 首页增加标志用于区分
navigation.forEach((item) => {
  if (item.meta) {
    item.meta.tab = true;
  }
});
const viewPage = import.meta.glob(['@/views/**/*.vue', '!/**/components/**/*.vue']);
const views = resolvePagesRoutes(viewPage, '/src/views');
const commonPage = import.meta.glob(['@/common/**/*.vue', '!/**/components/**/*.vue']);
const common = resolvePagesRoutes(commonPage, '/src/common');

const router = createRouter({
  history: createWebHashHistory(),
  routes: routes.concat(common).concat(views)
});
export default router;
